import java.util.Scanner;
public class T1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int T = scanner.nextInt();
        for (int t = 0; t < T; t++) {
            int a = 0, b = 0;
            String s = scanner.next();
            for (int i = 0; i < 5; i++) {
                if (s.charAt(i) == 'A') {
                    a++;
                } else {
                    b++;
                }
            }
            System.out.println(a > b ? 'A' : 'B');
        }

        scanner.close();
    }
}
